package com.spring.eurekaclient;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@RestController
public class UserController {

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/getUserList")
    public Object getUserList(HttpServletRequest request) {
        try {
            //模拟三秒返回结果
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List<User> list = new ArrayList<User>();
        User user = new User("张三", "qwe", 12);
        User user1 = new User("李四", "123456", 19);
        User user2 = new User("端口号", serverPort, 0);
        User user3 = new User("sessionId", request.getSession().getId(), 0);
        list.add(user);
        list.add(user1);
        list.add(user2);
        list.add(user3);
        return list;
    }
}
